package com.TreeSet;

import java.util.Comparator;
import java.util.TreeSet;

public class Demo2 {
    public static void main(String[] args) {
        TreeSet<String> ts=new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String s, String t1) {
                int result = s.length() - t1.length();
                result = result == 0 ? s.compareTo(t1) : result;
                return result;
            }
        });
        ts.add("a");
        ts.add("adsf");
        ts.add("er");
        ts.add("erd");
        System.out.println(ts);
    }


}
